//
//  CustomAnnotationVew.m
//  欢乐美食
//
//  Created by 遇水 on 15/7/6.
//  Copyright (c) 2015年 遇水. All rights reserved.
//

#import "CustomAnnotationVew.h"


#define kCalloutWidth       200.0
#define kCalloutHeight      70.0
@interface CustomAnnotationVew ()
@property (nonatomic, strong, readwrite) CustomCelloutView *calloutView;

@end

@implementation CustomAnnotationVew



- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    if (self.selected == selected)
    {
        return;
    }
    
    if (selected)
    {
        if (self.calloutView == nil)
        {
            self.calloutView = [[CustomCelloutView alloc] initWithFrame:CGRectMake(0, 0, kCalloutWidth, kCalloutHeight)];
            self.calloutView.center = CGPointMake(CGRectGetWidth(self.bounds) / 2.f + self.calloutOffset.x,
                                                  -CGRectGetHeight(self.calloutView.bounds) / 2.f + self.calloutOffset.y);
        }
        
        self.calloutView.image = [UIImage imageNamed:@"building"];
        self.calloutView.title = self.annotation.title;
        self.calloutView.subtitle = self.annotation.subtitle;
        
        [self addSubview:self.calloutView];
    }
    else
    {
        [self.calloutView removeFromSuperview];
    }
    
    [super setSelected:selected animated:animated];
}

@end
